package com.oepm.biz.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.oepm.biz.UserBiz;
import com.oepm.dao.entity.QueryInfo;
import com.oepm.dao.entity.UserPo;
import com.oepm.dao.entity.UserVo;
import com.oepm.dao.entity.UsersForm;
import com.oepm.dao.mapper.UserMapper;

import com.oepm.vo.DataVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserBizImpl implements UserBiz {
    @Resource
    UserMapper userMapper;


    public DataVo selectAll(String academy,QueryInfo queryInfo) {

        PageHelper.startPage(queryInfo.getPagenum(),queryInfo.getPagesize());
        List<UserVo> userVos = userMapper.selectAll(academy);
        PageInfo<UserVo> pi = new PageInfo<>(userVos);
        System.out.println(pi.getTotal());

        return new DataVo(pi.getTotal(),pi.getList());
    }

    @Override
    public int insertUsers(List<UsersForm> list) {
        return userMapper.insertUsers(list);
    }

    @Override
    public UserPo queryUserByUserId(String userId) {
        return userMapper.queryUserByUserId(userId);
    }

    @Override
    public String queryRoleName(String roleId) {
        return userMapper.queryRoleName(roleId);
    }

    @Override
    public String queryRoleNameByUserId(String userId) {
        return userMapper.queryRoleNameByUserId(userId);
    }

    @Override
    public List<String> queryRoleByRoleId(String roleId) {
        return userMapper.queryRoleByRoleId(roleId);
    }

    @Override
    public String queryRoleId(String id) {
        return userMapper.queryRoleId(id);
    }

    @Override
    public String queryRoleNameByRoleId(String roleId) {
        return userMapper.queryRoleNameByRoleId(roleId);
    }

    @Override
    public UserVo searchUser(UserVo userVo) {
        return userMapper.searchUser(userVo);
    }

    @Override
    public int addUser(UserVo userVo) {
        return userMapper.addUser(userVo);
    }

    @Override
    public int deleteUser(String id) {
        return userMapper.deleteUser(id);
    }

    @Override
    public int updateUser(UserPo userPo) {
        return userMapper.updateUser(userPo);
    }


}
